FROM php:7.3-fpm

RUN sed -i "s@http://deb.debian.org@https://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list \
    && sed -i 's|http://security.debian.org/debian-security|https://mirrors.tuna.tsinghua.edu.cn/debian-security|g' /etc/apt/sources.list \
    && apt-get update -y \
    && apt-get install wget -y

RUN apt-get install cabextract vim cron curl npm git libmcrypt-dev libevent-dev ruby zlib1g zlib1g.dev libpcre3-dev openssl libssl-dev libzip-dev libpng-dev --fix-missing -y \
    && apt-get install redis-server rabbitmq-server erlang -y \
    && npm config set registry https://registry.npm.taobao.org \
    && npm install n -g \
    && n lts \
    && apt-get clean all

RUN apt-get -y install --no-install-recommends wget gnupg ca-certificates \
    && wget -O - https://openresty.org/package/pubkey.gpg | apt-key add - \
    && codename=`grep -Po 'VERSION="[0-9]+ \(\K[^)]+' /etc/os-release` \
    && echo "deb http://openresty.org/package/debian $codename openresty" | tee /etc/apt/sources.list.d/openresty.list \
    && apt-get update \
    && apt-get -y install openresty

RUN apt-get install -y libfreetype6-dev libmcrypt-dev libjpeg-dev libpng-dev

RUN docker-php-ext-configure gd --with-jpeg-dir=/usr/include --with-png-dir=/usr/include --with-freetype-dir=/usr/include/freetype2

RUN docker-php-ext-install gd \
    && docker-php-ext-install zip \
    && docker-php-ext-install pcntl \
    && docker-php-ext-install bcmath \
    && docker-php-ext-install mysqli \
    && docker-php-ext-install sockets

RUN apt-get install -y librabbitmq-dev

RUN pecl install amqp \
    && pecl install event-3.0.4 \
    && pecl install redis-5.1.1 \
    && pecl install swoole-4.4.0 \
    && docker-php-ext-enable event \
    && docker-php-ext-enable swoole \
    && docker-php-ext-enable amqp \
    && docker-php-ext-enable redis \
    && pecl clear-cache

RUN apt-get install lib32stdc++6 -y \
    && apt-get clean all

RUN apt-get install vim -y \
    && apt-get clean all

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

COPY ./start/start.sh /var/